package ru.papergames.controller.commands
{
	import org.puremvc.as3.interfaces.INotification;
	import ru.papergames.controller.notifications.CoreNotifications;
	
	import ru.papergames.controller.commands.BaseCommand;
	import ru.papergames.model.vo.LoginVO;
	import ru.papergames.controller.notifications.FrontendNotifications;
	import ru.papergames.model.proxies.LoginProxy;

	public class LoginCommand extends BaseCommand
	{
		override public function execute(notification:INotification):void {
			super.execute(notification);
			
			switch( notification.getName() ) {
				case FrontendNotifications.TRY_LOGIN:
					
					var loginVO:LoginVO = notification.getBody() as LoginVO;
					
					loginProxy.doLogin(loginVO);
					
				break;
				
				case LoginProxy.LOGIN_SUCCESS:
					
					if (sessProxy) {
						sessProxy.startSessManPing();
					}
					
					facade.sendNotification(CoreNotifications.INITIALIZE_MESSAGING);
					
				break;
				
			}
			
			
		}	
				
	}
}